﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MG_POS_PC.Forms.Setting
{
    public partial class t_user_setting_form : BaseForm
    {
        private DataTable dt = null;
        private MG_POS_PC.DAL.Setting.t_user_setting dal = null;
        private MG_POS_PC.Model.Setting.t_user_setting model = null;
        private MG_POS_PC.BLL.Setting.t_user_setting bll = null;

        public t_user_setting_form()
        {
            InitializeComponent();
        }

        private void t_user_setting_form_Load(object sender, EventArgs e)
        {
            Display();
        }

        private void Display()
        {
            dal = new MG_POS_PC.DAL.Setting.t_user_setting();
            dt = dal.GetList("").Tables[0];
            listView1.Clear();
            for (int i = 0; i < dt.Columns.Count;i++ )
            {
                listView1.Columns.Add(dt.Columns[i].ColumnName.ToString().Trim(), 100, HorizontalAlignment.Center);
            }
            for (int j = 0; j < dt.Rows.Count;j++ )
            {
                ListViewItem lvi = listView1.Items.Add(dt.Rows[j][0].ToString());
                for (int i = 1; i < dt.Columns.Count; i++ )
                {
                    lvi.SubItems.Add(dt.Rows[j][i].ToString());
                }
            }
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            
        }

        private void btnDelete_Click(object sender, EventArgs e)
        {

        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            model = new MG_POS_PC.Model.Setting.t_user_setting();
            model.us_id = Util.FormatUtil.String2Int(Util.FormatUtil.getTxt(txtUs_id));
            model.us_login_id = Util.FormatUtil.getTxt(txtUs_login_id);
            model.us_pwd = Util.FormatUtil.getTxt(txtUs_pwd);
            model.us_color = Util.FormatUtil.String2Int(Util.FormatUtil.getCombobox(cmbUs_color));
            model.us_manager = chbUs_manager.Checked ? "Y" : "N";
            model.us_active = chbUs_active.Checked ? "Y" : "N";
            bll = new MG_POS_PC.BLL.Setting.t_user_setting();
            bll.Add(model);
        }

        
    }
}
